package com.dianping.cat.home.router.transform;
import com.dianping.cat.home.router.entity.DefaultServer;
import com.dianping.cat.home.router.entity.Domain;
import com.dianping.cat.home.router.entity.Group;
import com.dianping.cat.home.router.entity.GroupServer;
import com.dianping.cat.home.router.entity.Network;
import com.dianping.cat.home.router.entity.NetworkPolicy;
import com.dianping.cat.home.router.entity.RouterConfig;
import com.dianping.cat.home.router.entity.Server;
import com.dianping.cat.home.router.entity.ServerGroup;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/*  18 */     this.m_deferedJobs = new ArrayList();


/*  21 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
    for (Runnable job : this.m_deferedJobs) {
/*  26 */       job.run();
    }
  }


  public boolean onDefaultServer(final RouterConfig parent, final DefaultServer defaultServer) {
    if (this.m_deferrable) {
/*  33 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
              parent.addDefaultServer(defaultServer);
            }
          });
    } else {
/*  40 */       parent.addDefaultServer(defaultServer);
    }

/*  43 */     return true;
  }


  public boolean onDomain(final RouterConfig parent, final Domain domain) {
/*  48 */     if (this.m_deferrable) {
/*  49 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  52 */               parent.addDomain(domain);
            }
          });
    } else {
/*  56 */       parent.addDomain(domain);
    }

/*  59 */     return true;
  }


  public boolean onGroup(final Domain parent, final Group group) {
/*  64 */     if (this.m_deferrable) {
/*  65 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  68 */               parent.addGroup(group);
            }
          });
    } else {
/*  72 */       parent.addGroup(group);
    }

/*  75 */     return true;
  }


  public boolean onGroupServer(final ServerGroup parent, final GroupServer groupServer) {
/*  80 */     if (this.m_deferrable) {
/*  81 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  84 */               parent.addGroupServer(groupServer);
            }
          });
    } else {
/*  88 */       parent.addGroupServer(groupServer);
    }

/*  91 */     return true;
  }


  public boolean onNetwork(final NetworkPolicy parent, final Network network) {
/*  96 */     if (this.m_deferrable) {
/*  97 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 100 */               parent.addNetwork(network);
            }
          });
    } else {
/* 104 */       parent.addNetwork(network);
    }

/* 107 */     return true;
  }


  public boolean onNetworkPolicy(final RouterConfig parent, final NetworkPolicy networkPolicy) {
/* 112 */     if (this.m_deferrable) {
/* 113 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 116 */               parent.addNetworkPolicy(networkPolicy);
            }
          });
    } else {
/* 120 */       parent.addNetworkPolicy(networkPolicy);
    }

/* 123 */     return true;
  }


  public boolean onServer(Group parent, Server server) {
/* 128 */     parent.addServer(server);
/* 129 */     return true;
  }


  public boolean onServerGroup(final RouterConfig parent, final ServerGroup serverGroup) {
/* 134 */     if (this.m_deferrable) {
/* 135 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 138 */               parent.addServerGroup(serverGroup);
            }
          });
    } else {
/* 142 */       parent.addServerGroup(serverGroup);
    }

/* 145 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/classes/!/com/dianping/cat/home/router/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */